package com.rerun.controller.base;
import java.util.List;
import java.util.Map;

import com.rerun.common.bean.Rest;
import com.rerun.common.controller.SuperController;
import com.rerun.entity.vo.JobMessageVo;
import com.rerun.service.IJobService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * The type China city controller.
 */
@Controller
@RequestMapping("/jobMessage")
public class JobMessageController extends SuperController{
    /**
     * The Province service.
     */
    @Autowired
	private IJobService jobService;
    /**
     * 后台职位管理列表
     * @param model
     * @param map
     * @param pageNumber
     * @param pageSize
     * @return
     * @throws Exception
     */

    @RequestMapping(value="/showjobMessage/{pageNumber}",method = RequestMethod.GET)
    public String showjobMessage(Model model ,@RequestParam (defaultValue="") Map<String, Object> map, @PathVariable("pageNumber") Integer pageNumber, 
    		@RequestParam(defaultValue = "15") Integer pageSize) throws Exception{
    	//获取页码 条数
		 model.addAttribute("pageSize", pageSize);
         List<JobMessageVo> list = jobService.showjobMessage(map, pageNumber, pageSize);
    	 
    	 model.addAttribute("list", list);
    	 
    	return "business/jobMessage/jobList";
    }
    
  
	
	/**
     *  后台职位管理列表编辑查询回显
     */
	@RequestMapping(value="/editMessagePage/{id}",method = RequestMethod.GET)

    public String findjobMessage(Model model,@PathVariable(value="id") String id){
		
		JobMessageVo jobMessage = jobService.findjobMessage(id);
		model.addAttribute("jobMessage", jobMessage);
		return "business/jobMessage/edit";
    }
	/**
     * 后台职位列表编辑页面
     */
	@RequestMapping(value="/editMessage",method = RequestMethod.POST)
	@ResponseBody
	public Rest editMessage(JobMessageVo JobMessage ){
		
		return jobService.updateJobMessage(JobMessage);
	}
	
}
